<template>
	<view class="container index">
		<!-- 头部导航 -->
		<nav-bar bgColor="#4c8aed" title="医院详情" />
			<image class="bg" :src="detail.hospitalBg"></image>
			<view class="detail_info">
				<view class="info flex">
					<image :src="detail.hospitalBg"></image>
					<view class="cont">
						<view class="list_item_title">{{detail.hospitalName}}</view>
						<view class="list_item_center">
							<text class="list_item_level">{{detail.grade}}</text>
						</view>
					</view>
				</view>
				<view class="list_item_address">
					<image class="icon" src="/static/icon/address.png"/>
					{{detail.address}}
				</view>
				<view class="desc">{{detail.profile}}</view>
			</view>
			<view class="object_card">
				<view class="index_title">选择服务项目</view>
				<view class="list">
						<view class="item" v-for="(item,index) in detail.accompanyList" :key="index">
							<image class="icon" :src="item.accompanyIcon" mode="aspectFill"></image>
							<text class="title">{{item.accompanyName}}</text>
							<view class="right">
								<text class="price">{{item.accompanyFee}}</text>
								<text class="gray">/</text>
								次<at-icon value="chevron-right" size="20" color="#999999"></at-icon>
								<text class="btn_order" @click="commit(item)">下单</text>
							</view>
						</view>
				</view>
			</view>
			<view class="fixed-bottom">
				<view class="b-card">
					<button class="add-btn no-border" @click="commit()">一键下单</button>
				</view>
			</view>
		</view>
</template>
<script>
	import { mapState } from 'vuex';
	export default {
		components: {
		},
		data() {
			return {
				detail: {}
			}
		},
		computed: {
			...mapState(['hasLogin','userInfo']),
		},
		onLoad(options){
			this.titleBar = this.titleBarHeight
			this.getDetail(options.hospitalId)
		},
		methods: {
			async getDetail(hospitalId) {
				const { code,data } = await this.$apis.postApi('/hospital/getById',{hospitalId})
				if(code==200){
					this.detail = data
				}
			},
			async getDetail(hospitalId) {
				const { code,data } = await this.$apis.postApi('/hospital/getById',{hospitalId})
				if(code==200){
					this.detail = data
				}
			},
			async commit(item) {
				const params = {
					hospitalId: this.detail.hospitalId,
					hospitalName: this.detail.hospitalName
				}
				if(item&&item.accompanyName) {
					params.accompanySelect = [{ name:item.accompanyName, id: item.accompanyId }]
				}
				uni.navigateTo({
					url: '/userPages/onlineOrder?params='+encodeURIComponent(JSON.stringify(params))
				})
			},
			
		}
	}
</script>
<style lang="scss" scoped>
@import "./detail.scss";
</style>
